<?php
autenticacao("marca");
$exc_marca = $_GET["exc_marca"];
if($exc_marca != '' && valida::numero($exc_marca)){
        $excconf = $_GET["excconf"];
        if($excconf == 1){
                $marca = new Marca();
                $marca->excluir($id_marca);
                header("location: ".url("pag", "marca"));
        }else{
                echo "
                <script>
                var p = window.confirm('Tem certeza que deseja excluir esta marca?');
                window.location=(p) ? '".url("pag", "marca")."&id_marca=$id_marca&exc_marca=$id_marca&excconf=1' : '';
                </script>";
        }
}

echo "
        <table class='tabela'>
                <tr>
                        <th><label>ID</label></th>
                        <th><label>Nome</label></th>
                        <th><label>CNPJ</label></th>
                        <th><label>Endereço</label></th>
                        <th><label>Revendedor</label></th>
                        <th><label>Telefone</label></th>
                        <th><label>Observações</label></th>
                        <th class='np'><label> </label></th>
                </tr>";
$cor[0] = "#FFF";
$cor[1] = "#DDD";
$cnt = 0;
$sql = "select id from Marca";
$conexao = db::conecta();
$result  = db::query($sql, $conexao);
while ($id = db::fetch_array($result)){
        $marca = new Marca();
        $marca->carregar($id[0]);
        echo "
                <tr style='background: ".$cor[$cnt]."'>
                        <td><label>".$marca->get_id()."</label></td>
                        <td class='bot_tabela'><label>".$marca->get_nome()."</label></td>
                        <td><label>".$marca->get_cnpj()."</label></td>
                        <td><label>".$marca->get_endereco()."</label></td>
                        <td><label>".$marca->get_revendedor()."</label></td>
                        <td><label>(".$marca->get_ddd().") ".$marca->get_telefone()."</label></td>
                        <td><label>".$marca->get_observacoes()."</label></td>
                        <td class='np'><a href='".url("pag", "marca_set")."&id_marca=".$marca->get_id()."' name='Alterar'><button class='botaoalterarlista'> </button></a></td>
                </tr>";
        if($cnt == 1){ $cnt = 0; }else{ $cnt = 1; }
}
db::close($conexao);
echo "
        </table>
        <a href='".url("pag", "marca_set")."' name='Novo'><button class='botaonovo'><label>Novo</label></button></a>
        <button class='botaoimprimir' onClick='window.print()'><label>Imprimir</label></button>
        <br /><br />
        <a href='".url("pag", "estoque")."' name='Voltar'><button class='botaovoltar'><label>Voltar</label></button></a>";

?>